package leo.game.stage
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	/**
	 * 舞台基类 
	 * @author leo
	 * 
	 */	
	public class BaseStage extends Sprite
	{
		private var refreshTimer :Timer;
		private var _refreshInterval :int = 0;
		public function BaseStage()
		{
			super();
			addEventListener(MouseEvent.MOUSE_DOWN,mouseHandler);
			addEventListener(MouseEvent.MOUSE_UP,mouseHandler);
			addEventListener(MouseEvent.MOUSE_OVER,mouseHandler);
			addEventListener(MouseEvent.MOUSE_OUT,mouseHandler);
			addEventListener(MouseEvent.MOUSE_MOVE,mouseHandler);
		}
		
		public function destory():void
		{
			
		}

		public function get refreshInterval():int
		{
			return _refreshInterval;
		}

		/**
		 * 自動刷新间隔，默认为不刷新 
		 * @param value
		 * 
		 */		
		public function set refreshInterval(value:int):void
		{
			if(value == _refreshInterval) return;
			_refreshInterval = value;
			
			if(value == 0)
			{
				if(refreshTimer)
				{
					refreshTimer.removeEventListener(TimerEvent.TIMER,refreshHandler);
					refreshTimer.stop();
					refreshTimer = null;
				}
			}else
			{
				if(!refreshTimer)
				{
					refreshTimer = new Timer(value,int.MAX_VALUE);
					refreshTimer.addEventListener(TimerEvent.TIMER,refreshHandler);
					refreshTimer.start();
				}
			}
			
		}
		
		protected function refreshHandler(event :TimerEvent):void
		{
			
		}
		
		protected function mouseHandler(event :MouseEvent):void
		{
			
		}

	}
}